﻿using MySql.Data.MySqlClient;
using System;
using System.Collections.Generic;
using System.Data.Common;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using YunSpace.Core;
using YunSpace.Data;
using YunSpace.Domain.Entity.MiniSite;
using YunSpace.Domain.IRepository.MiniSite;
using YunSpace.Domain.ViewModel.MiniSite;
using YunSpace.Repository.MiniSite;

namespace YunSpace.Application.MiniSite
{
    public class HomeApp
    {
        public MyMineFlagsViewModel GetMyMineFlags(string customerId) {
            using (var db = new RepositoryBase()) {
                var strSql = @"select 
                                (select Count(1) from MiniSite_SiteOrder so1 where so1.F_IsComment = 0 and so1.F_CustomerId = @customerId) as CommentCount, 
                                (select Count(1)  from MiniSite_SiteOrder so2 where so2.F_Status in(0,2) and so2.F_CustomerId = @customerId) as OrderCount";

                DbParameter[] parameter =
                {
                   new MySqlParameter("@customerId",customerId)
                };
                return db.FirstOrDefault<MyMineFlagsViewModel>(strSql, parameter);
            }
        }

    }
}
